\(\int (a+b \sec ^2(e+f x))^2 \, dx\) [333]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 14, antiderivative size = 40 \[ \int \left (a+b \sec ^2(e+f x)\right )^2 \, dx=a^2 x+\frac {b (2 a+b) \tan (e+f x)}{f}+\frac {b^2 \tan ^3(e+f x)}{3 f} \]

[Out]

a^2*x+b*(2*a+b)*tan(f*x+e)/f+1/3*b^2*tan(f*x+e)^3/f

Rubi [A] (verified)

Time = 0.03 (sec) , antiderivative size = 40, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.214, Rules used = {4213, 398, 209} \[ \int \left (a+b \sec ^2(e+f x)\right )^2 \, dx=a^2 x+\frac {b (2 a+b) \tan (e+f x)}{f}+\frac {b^2 \tan ^3(e+f x)}{3 f} \]

[In]

Int[(a + b*Sec[e + f*x]^2)^2,x]

[Out]

a^2*x + (b*(2*a + b)*Tan[e + f*x])/f + (b^2*Tan[e + f*x]^3)/(3*f)

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 398

Int[((a_) + (b_.)*(x_)^(n_))^(p_)*((c_) + (d_.)*(x_)^(n_))^(q_), x_Symbol] :> Int[PolynomialDivide[(a + b*x^n)
^p, (c + d*x^n)^(-q), x], x] /; FreeQ[{a, b, c, d}, x] && NeQ[b*c - a*d, 0] && IGtQ[n, 0] && IGtQ[p, 0] && ILt
Q[q, 0] && GeQ[p, -q]

Rule 4213

Int[((a_) + (b_.)*sec[(e_.) + (f_.)*(x_)]^2)^(p_), x_Symbol] :> With[{ff = FreeFactors[Tan[e + f*x], x]}, Dist
[ff/f, Subst[Int[(a + b + b*ff^2*x^2)^p/(1 + ff^2*x^2), x], x, Tan[e + f*x]/ff], x]] /; FreeQ[{a, b, e, f, p},
 x] && NeQ[a + b, 0] && NeQ[p, -1]

Rubi steps \begin{align*} \text {integral}& = \frac {\text {Subst}\left (\int \frac {\left (a+b+b x^2\right )^2}{1+x^2} \, dx,x,\tan (e+f x)\right )}{f} \\ & = \frac {\text {Subst}\left (\int \left (b (2 a+b)+b^2 x^2+\frac {a^2}{1+x^2}\right ) \, dx,x,\tan (e+f x)\right )}{f} \\ & = \frac {b (2 a+b) \tan (e+f x)}{f}+\frac {b^2 \tan ^3(e+f x)}{3 f}+\frac {a^2 \text {Subst}\left (\int \frac {1}{1+x^2} \, dx,x,\tan (e+f x)\right )}{f} \\ & = a^2 x+\frac {b (2 a+b) \tan (e+f x)}{f}+\frac {b^2 \tan ^3(e+f x)}{3 f} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.14 (sec) , antiderivative size = 41, normalized size of antiderivative = 1.02 \[ \int \left (a+b \sec ^2(e+f x)\right )^2 \, dx=\frac {3 a^2 f x+3 b (2 a+b) \tan (e+f x)+b^2 \tan ^3(e+f x)}{3 f} \]

[In]

Integrate[(a + b*Sec[e + f*x]^2)^2,x]

[Out]

(3*a^2*f*x + 3*b*(2*a + b)*Tan[e + f*x] + b^2*Tan[e + f*x]^3)/(3*f)

Maple [A] (verified)

Time = 0.54 (sec) , antiderivative size = 46, normalized size of antiderivative = 1.15

method result size
parts \(a^{2} x -\frac {b^{2} \left (-\frac {2}{3}-\frac {\sec \left (f x +e \right )^{2}}{3}\right ) \tan \left (f x +e \right )}{f}+\frac {2 a b \tan \left (f x +e \right )}{f}\) \(46\)
derivativedivides \(\frac {a^{2} \left (f x +e \right )+2 a b \tan \left (f x +e \right )-b^{2} \left (-\frac {2}{3}-\frac {\sec \left (f x +e \right )^{2}}{3}\right ) \tan \left (f x +e \right )}{f}\) \(48\)
default \(\frac {a^{2} \left (f x +e \right )+2 a b \tan \left (f x +e \right )-b^{2} \left (-\frac {2}{3}-\frac {\sec \left (f x +e \right )^{2}}{3}\right ) \tan \left (f x +e \right )}{f}\) \(48\)
risch \(a^{2} x +\frac {4 i b \left (3 a \,{\mathrm e}^{4 i \left (f x +e \right )}+6 a \,{\mathrm e}^{2 i \left (f x +e \right )}+3 b \,{\mathrm e}^{2 i \left (f x +e \right )}+3 a +b \right )}{3 f \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )^{3}}\) \(68\)
norman \(\frac {a^{2} x \tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{6}-a^{2} x +3 a^{2} x \tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{2}-3 a^{2} x \tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{4}-\frac {2 b \left (2 a +b \right ) \tan \left (\frac {f x}{2}+\frac {e}{2}\right )}{f}-\frac {2 b \left (2 a +b \right ) \tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{5}}{f}+\frac {4 b \left (6 a +b \right ) \tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{3}}{3 f}}{\left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{2}-1\right )^{3}}\) \(138\)
parallelrisch \(\frac {3 x \tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{6} a^{2} f +\left (-12 a b -6 b^{2}\right ) \tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{5}-9 x \tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{4} a^{2} f +\left (24 a b +4 b^{2}\right ) \tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{3}+9 x \tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{2} a^{2} f +\left (-12 a b -6 b^{2}\right ) \tan \left (\frac {f x}{2}+\frac {e}{2}\right )-3 a^{2} f x}{3 f \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )-1\right )^{3} \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )+1\right )^{3}}\) \(158\)

[In]

int((a+b*sec(f*x+e)^2)^2,x,method=_RETURNVERBOSE)

[Out]

a^2*x-b^2/f*(-2/3-1/3*sec(f*x+e)^2)*tan(f*x+e)+2*a*b/f*tan(f*x+e)

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 58, normalized size of antiderivative = 1.45 \[ \int \left (a+b \sec ^2(e+f x)\right )^2 \, dx=\frac {3 \, a^{2} f x \cos \left (f x + e\right )^{3} + {\left (2 \, {\left (3 \, a b + b^{2}\right )} \cos \left (f x + e\right )^{2} + b^{2}\right )} \sin \left (f x + e\right )}{3 \, f \cos \left (f x + e\right )^{3}} \]

[In]

integrate((a+b*sec(f*x+e)^2)^2,x, algorithm="fricas")

[Out]

1/3*(3*a^2*f*x*cos(f*x + e)^3 + (2*(3*a*b + b^2)*cos(f*x + e)^2 + b^2)*sin(f*x + e))/(f*cos(f*x + e)^3)

Sympy [F]

\[ \int \left (a+b \sec ^2(e+f x)\right )^2 \, dx=\int \left (a + b \sec ^{2}{\left (e + f x \right )}\right )^{2}\, dx \]

[In]

integrate((a+b*sec(f*x+e)**2)**2,x)

[Out]

Integral((a + b*sec(e + f*x)**2)**2, x)

Maxima [A] (verification not implemented)

none

Time = 0.18 (sec) , antiderivative size = 44, normalized size of antiderivative = 1.10 \[ \int \left (a+b \sec ^2(e+f x)\right )^2 \, dx=a^{2} x + \frac {{\left (\tan \left (f x + e\right )^{3} + 3 \, \tan \left (f x + e\right )\right )} b^{2}}{3 \, f} + \frac {2 \, a b \tan \left (f x + e\right )}{f} \]

[In]

integrate((a+b*sec(f*x+e)^2)^2,x, algorithm="maxima")

[Out]

a^2*x + 1/3*(tan(f*x + e)^3 + 3*tan(f*x + e))*b^2/f + 2*a*b*tan(f*x + e)/f

Giac [A] (verification not implemented)

none

Time = 0.29 (sec) , antiderivative size = 49, normalized size of antiderivative = 1.22 \[ \int \left (a+b \sec ^2(e+f x)\right )^2 \, dx=\frac {b^{2} \tan \left (f x + e\right )^{3} + 3 \, {\left (f x + e\right )} a^{2} + 6 \, a b \tan \left (f x + e\right ) + 3 \, b^{2} \tan \left (f x + e\right )}{3 \, f} \]

[In]

integrate((a+b*sec(f*x+e)^2)^2,x, algorithm="giac")

[Out]

1/3*(b^2*tan(f*x + e)^3 + 3*(f*x + e)*a^2 + 6*a*b*tan(f*x + e) + 3*b^2*tan(f*x + e))/f

Mupad [B] (verification not implemented)

Time = 19.57 (sec) , antiderivative size = 42, normalized size of antiderivative = 1.05 \[ \int \left (a+b \sec ^2(e+f x)\right )^2 \, dx=\frac {\frac {b^2\,{\mathrm {tan}\left (e+f\,x\right )}^3}{3}-\mathrm {tan}\left (e+f\,x\right )\,\left (b^2-2\,b\,\left (a+b\right )\right )+a^2\,f\,x}{f} \]

[In]

int((a + b/cos(e + f*x)^2)^2,x)

[Out]

((b^2*tan(e + f*x)^3)/3 - tan(e + f*x)*(b^2 - 2*b*(a + b)) + a^2*f*x)/f